<style lang="less" scoped>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }

  .avatar-uploader .el-upload:hover {
    border-color: #20a0ff;
  }

  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }

  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .my {
    margin-left: -60px;
  }

  .el-table {
    flex: 1;
    .el-icon-check {
      display: none;
    }
    .current-row {
      .el-icon-check {
        display: inline-block;
      }
    }

  }

  .el-dialog {
    flex: 1;
    .isreceipt {
      display: none;
    }
    .receipt {
      display: inline-block;
    }
  }
  .dialog-form-label{
    label{
      width: 120px;
    }

  }
  .dialog-form-content{
    width: 350px
  }
</style>

<template>
  <el-tabs type="card">
    <!--以下为待收取-->
    <el-tab-pane label="待收取">
      <section>
        <!--工具条-->
        <search-bar more-display>
          <el-row>
            <el-col :span="8">
              <el-form-item label="客户名称">
                <el-input  v-model="waitGather['LIKE_order.memberUserName']" placeholder="请输入客户名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="订单编号">
                <el-input  v-model="waitGather.LIKE_orderNumber" placeholder="请输入订单编号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="收货人">
                <el-input  v-model="waitGather.LIKE_sendContactName"
                          placeholder="请输入收货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <!-- todo
            <el-col :span="8">
              <el-form-item label="签收日期">
                <el-date-picker
                  type="daterange"
                  align="right"
                  placeholder="选择日期范围">
                </el-date-picker>
              </el-form-item>
            </el-col>-->
            <el-col :span="8">
              <el-form-item label="发货人">
                <el-input  v-model="waitGather.LIKE_shipmentsContactName"
                          placeholder="请输入发货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </search-bar>
        <!-- 操作 -->
        <el-col :span="24" style="margin-bottom: 10px">
          <el-button type="primary" @click="waitGatherBtn">回单收取</el-button>
          <el-button type="primary" @click="gatherAbnormalRegister">异常登记</el-button>
          <el-button type="primary">导出</el-button>
          <el-button type="primary" @click="waitGatherResert" style="float: right">重置</el-button>
          <el-button type="primary" @click="waitGatherSearch" style="float: right">查询</el-button>
        </el-col>
        <!-- 未收取  表格-->
        <el-table :data="waitGatherTableData" highlight-current-row border max-height="600"
                   @selection-change="selsChange" v-loading="listLoading" style="width: 100%;">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column prop="orderNumber" label="订单编号" width="160" >
          </el-table-column>
          <el-table-column prop="orderCreateDate" label="下单日期" width="180" >
          </el-table-column>
          <el-table-column prop="signDate" label="签收日期" width="180" >
          </el-table-column>
          <el-table-column prop="receiptWayName" label="回单类型" width="130" >
          </el-table-column>
          <el-table-column prop="abnormalName" label="异常状态" width="110">
          </el-table-column>
          <el-table-column prop="memberUserName" label="客户名称" >
          </el-table-column>
          <el-table-column prop="shipmentsContactName" label="发货人" width="110" >
          </el-table-column>
          <el-table-column prop="shipmentsContactPhone" label="发货人手机" width="140" >
          </el-table-column>
          <el-table-column prop="sendContactName" label="收货人" width="110" >
          </el-table-column>
          <el-table-column prop="sendContactPhone" label="收货人手机" width="140" >
          </el-table-column>
          <el-table-column prop="sendAddress" label="图片" width="100" >
            <template slot-scope="scope">
              <el-button type="primary"
                         @click="examinePicture(scope.$index, scope.row)">
                查看图片
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination
            :current-page="currentPage"
            :page-size="pageSize"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            layout="total,sizes,prev, pager, next, jumper"
            :total="total" style="float: right">
          </el-pagination>
        </el-col>
        <!--待收取--回单收取弹窗-->
        <el-dialog :title="waitGatherTialogTitle" size="tiny" :visible.sync="waitGatherVisible"
                   :close-on-click-modal="false">
          <el-form :model="waitGatherModel" label-width="120px" ref="waitGatherModel">
            <el-form-item  label="收单人"
                          :rules="[{required: true, message: '收单人不能为空', trigger: 'change' }]"
                          prop="acquirerName">
              <el-input v-model="waitGatherModel.acquirerName" class="dialog-form-content"></el-input>
            </el-form-item>
            <el-form-item  label="收取日期"
                          :rules="[{type: 'date', required: true, message: '收取日期不能为空', trigger: 'change' }]"
                          prop="acquirerDate">
              <el-date-picker
                              style="width: 350px"
                              v-model="waitGatherModel.acquirerDate"
                              type="date"
                              placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item  label="备注" prop="remark">
              <el-input type="textarea"
                        class="dialog-form-content"
                        :autosize="{ minRows: 5, maxRows: 10}"
                        v-model="waitGatherModel.remark">
              </el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="waitGatherVisible = false">取消</el-button>
            <el-button type="primary" @click.native="saveWaitGather">提交
            </el-button>
          </div>
        </el-dialog>
        <!--待收取--回单收取弹窗   end -->
        <!--签收查看图片  弹窗-->
        <el-dialog :title="pictureTitle" size="tiny" :visible.sync="pcctureVisible"
                   :close-on-click-modal="false">
          <el-form label-width="100px">
            <template v-for="(item,index) in SignOffPictcure">
              <li :key="index">
                <img width="100%" height="100%" v-bind:src="item.signOffPicture">
              </li>
            </template>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="pcctureVisible = false">取消</el-button>
          </div>
        </el-dialog>
        <!--待收取--异常登记-->
        <el-dialog :title="waitGatherAbnormalTialogTitle" size="tiny" :visible.sync="waitGatherAbnormalVisible"
                   :close-on-click-modal="false">
          <el-form :model="waitGatherAbnormalModel" label-width="120px" ref="waitGatherAbnormalModel">
            <el-form-item  label="异常类型">
              <el-select v-model="waitGatherAbnormalModel.abnormal"
                         @visible-change="waitReturnAbnormalSelect" class="dialog-form-content" placeholder="请选择异常类型">
                <el-option
                  v-for="item in waitReturnAbnormal"
                  :label="item.cnDictValname"
                  :key="item.dictVal"
                  :value="item.dictVal">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item  label="异常描述">
              <el-input type="textarea"
                        class="dialog-form-content"
                        spellcheck="请输入异常描述"
                        :autosize="{ minRows: 5, maxRows: 10}"
                        v-model="waitGatherAbnormalModel.abnormalExplain">
              </el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="waitReturnAbnormalVisible = false">取消</el-button>
            <el-button type="primary" @click.native="savewaitGatherAbnormal">提交
            </el-button>
          </div>
        </el-dialog>
      </section>
    </el-tab-pane>

    <!-- --------待返还--------------------------------------------------------------------------------------------------------------  -->
    <!--以下为待返还-->
    <el-tab-pane label="待返还">
      <section>
        <!--工具条-->
        <search-bar more-display>
          <el-row>
            <el-col :span="8">
              <el-form-item label="客户名称">
                <el-input  v-model="waitReturn['LIKE_order.memberUserName']" placeholder="请输入客户名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="订单编号">
                <el-input  v-model="waitReturn.LIKE_orderNumber" placeholder="请输入订单编号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="收货人">
                <el-input  v-model="waitReturn.LIKE_sendContactName"
                          placeholder="请输入收货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <!-- todo
            <el-col :span="8">
              <el-form-item label="签收日期">
                <el-date-picker
                  v-model="waitReturnPicker"
                  type="daterange"
                  align="right"
                  placeholder="选择日期范围">
                </el-date-picker>
              </el-form-item>
            </el-col>-->
            <el-col :span="8">
              <el-form-item label="发货人">
                <el-input  v-model="waitReturn.LIKE_shipmentsContactName"
                          placeholder="请输入发货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- todo
          <el-row>
            <el-col :span="8">
              <el-form-item label="收单日期">
                <el-date-picker
                  v-model="waitReturnPicker2"
                  type="daterange"
                  align="right"
                  placeholder="选择日期范围1"
                  :picker-options="pickerOptions2">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>-->
        </search-bar>
        <!-- 操作 -->
        <el-col :span="24" style="margin-bottom: 10px">
          <el-button type="primary" @click="waitReutrn">回单返还</el-button>
          <el-button type="primary" @click="abnormalRegister">异常登记</el-button>
          <el-button type="primary">导出</el-button>
          <el-button type="primary" @click="waitReturnRestert" style="float: right">重置</el-button>
          <el-button type="primary" @click="waitReturnSearch" style="float: right">查询</el-button>
        </el-col>
        <!-- 待返还  表格-->
        <el-table :data="waitReturnTableData" highlight-current-row border max-height="600"
                   @selection-change="selsChange1" v-loading="listLoading1"
                  style="width: 100%;">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column prop="orderNumber" label="订单编号" width="150">
          </el-table-column>
          <el-table-column prop="orderCreateDate" label="下单日期" width="175">
          </el-table-column>
          <el-table-column prop="signDate" label="签收日期" width="175">
          </el-table-column>
          <el-table-column prop="acquirerDate" label="收单日期" width="175">
          </el-table-column>
          <el-table-column prop="receiptWayName" label="回单类型" width="110">
          </el-table-column>
          <el-table-column prop="abnormalName" label="异常状态" width="110">
          </el-table-column>
          <el-table-column prop="memberUserName" label="客户名称">
          </el-table-column>
          <el-table-column prop="shipmentsContactName" label="发货人" width="80" >
          </el-table-column>
          <el-table-column prop="shipmentsContactPhone" label="发货人手机" width="130" >
          </el-table-column>
          <el-table-column prop="sendContactName" label="收货人" width="80" >
          </el-table-column>
          <el-table-column prop="sendContactPhone" label="收货人手机" width="130" >
          </el-table-column>
          <el-table-column prop="sendAddress" label="图片" width="100" >
            <template slot-scope="scope">
              <el-button type="primary"
                         @click="examinePicture(scope.$index, scope.row)">
                查看图片
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination
            :current-page="currentPage1"
            :page-size="pageSize1"
            @size-change="handleSizeChange1"
            @current-change="handleCurrentChange1"
            layout="total,sizes,prev, pager, next, jumper"
            :total="total1" style="float: right">
          </el-pagination>
        </el-col>
        <!--待返还--回单返还弹窗-->
        <el-dialog :title="waitReturnTialogTitle" size="tiny" :visible.sync="waitReturnVisible"
                   :close-on-click-modal="false">
          <el-form :model="waitReturnModel" label-width="120px" ref="waitReturnModel">
            <el-form-item
                          :rules="[{required: true, message: '收单人不能为空', trigger: 'change' }]"
                          prop="acquirerName"
                          label="收单人">
              <el-input class="dialog-form-content"  v-model="waitReturnModel.acquirerName">
              </el-input>
            </el-form-item>
            <el-form-item
                          :rules="[{type: 'date', required: true, message: '返还日期不能为空', trigger: 'change' }]"
                          prop="returnDate"
                          label="返还日期">
              <el-date-picker
                              v-model="waitReturnModel.returnDate"
                              type="date"
                              class="dialog-form-content"
                              placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item  label="备注" prop="remark">
              <el-input type="textarea"
                        class="dialog-form-content"
                        :autosize="{ minRows: 5, maxRows: 10}"
                        v-model="waitReturnModel.remark">
              </el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="waitReturnVisible = false">取消</el-button>
            <el-button type="primary" @click.native="saveWaitReturn">提交
            </el-button>
          </div>
        </el-dialog>
        <!--待返还--回单收取弹窗   end -->
        <!--待返还--异常登记-->
        <el-dialog :title="waitReturnAbnormalTialogTitle" size="tiny" :visible.sync="waitReturnAbnormalVisible"
                   :close-on-click-modal="false">
          <el-form :model="waitReturnAbnormalModel" label-width="120px" ref="waitReturnAbnormalModel">
            <el-form-item  label="异常类型">
              <el-select v-model="waitReturnAbnormalModel.abnormal"
                         @visible-change="waitReturnAbnormalSelect" class="dialog-form-content" placeholder="请选择异常类型">
                <el-option
                  v-for="item in waitReturnAbnormal"
                  :label="item.cnDictValname"
                  :key="item.dictVal"
                  :value="item.dictVal">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item  label="异常描述">
              <el-input type="textarea"
                        class="dialog-form-content"
                        spellcheck="请输入异常描述"
                        :autosize="{ minRows: 5, maxRows: 10}"
                        v-model="waitReturnAbnormalModel.abnormalExplain">
              </el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="waitReturnAbnormalVisible = false">取消</el-button>
            <el-button type="primary" @click.native="savewaitReturnAbnormal">提交
            </el-button>
          </div>
        </el-dialog>
      </section>
    </el-tab-pane>

    <!-- --------已返还--------------------------------------------------------------------------------------------------------------  -->
    <!--以下为已返还-->
    <el-tab-pane label="已返还">
      <section>
        <!--工具条-->
        <search-bar more-display>
          <el-row>
            <el-col :span="8">
              <el-form-item label="客户名称">
                <el-input  v-model="alreadyReturn['LIKE_order.memberUserName']" placeholder="请输入客户名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="订单编号">
                <el-input  v-model="alreadyReturn.LIKE_orderNumber" placeholder="请输入订单编号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="收货人">
                <el-input  v-model="alreadyReturn.LIKE_sendContactName"
                          placeholder="请输入收货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <!-- todo
            <el-col :span="8">
              <el-form-item label="签收日期">
                <el-date-picker
                  v-model="alreadyReturnPicker"
                  type="daterange"
                  align="right"
                  placeholder="选择日期范围"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            -->
            <el-col :span="8">
              <el-form-item label="发货人">
                <el-input  v-model="alreadyReturn.LIKE_shipmentsContactName"
                          placeholder="请输入发货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- todo
          <el-row>
            <el-col :span="8">
              <el-form-item label="收单日期">
                <el-date-picker
                  v-model="alreadyReturnPicker2"
                  type="daterange"
                  align="right"
                  placeholder="选择日期范围"
                  :picker-options="pickerOptions2"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="返还日期">
                <el-date-picker

                  v-model="alreadyReturnPicker3"
                  type="daterange"
                  align="right"
                  placeholder="选择日期范围"
                  :picker-options="pickerOptions2"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>-->
        </search-bar>
        <!-- 操作 -->
        <el-col :span="24" style="margin-bottom: 10px">
          <el-button type="primary">导出</el-button>
          <el-button type="primary" @click="alreadyReturnReset" style="float: right">重置</el-button>
          <el-button type="primary" @click="alreadyReturnSearch" style="float: right">查询</el-button>
        </el-col>
        <!-- 已返还  表格-->
        <el-table :data="alreadyReturnTableData" highlight-current-row border max-height="600"
                  @selection-change="selsChange2" v-loading="listLoading2"
                  style="width: 100%;">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column prop="orderNumber" label="订单编号" width="150" >
          </el-table-column>
          <el-table-column prop="orderCreateDate" label="下单日期" width="175" >
          </el-table-column>
          <el-table-column prop="signDate" label="签收日期" width="175" >
          </el-table-column>
          <el-table-column prop="acquirerDate" label="收单日期" width="175" >
          </el-table-column>
          <el-table-column prop="aleryReturnDate" label="返单日期" width="175">
          </el-table-column>
          <el-table-column prop="receiptWayName" label="回单类型" width="130" >
          </el-table-column>
          <el-table-column prop="abnormalName" label="异常状态" width="110">
          </el-table-column>
          <el-table-column prop="memberUserName" label="客户名称" width="130" >
          </el-table-column>
          <el-table-column prop="shipmentsContactName" label="发货人" width="110" >
          </el-table-column>
          <el-table-column prop="shipmentsContactPhone" label="发货人手机" width="140" >
          </el-table-column>
          <el-table-column prop="sendContactName" label="收货人" width="110" >
          </el-table-column>
          <el-table-column prop="sendContactPhone" label="收货人手机" width="140" >
          </el-table-column>
          <el-table-column prop="sendAddress" label="图片" width="100" >
            <template slot-scope="scope">
              <el-button type="primary"
                         @click="examinePicture1(scope.$index, scope.row)">
                查看图片
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--签收查看图片 1 弹窗-->
        <el-dialog :title="pictureTitle1" size="tiny" :visible.sync="pcctureVisible1"
        >
          <el-form label-width="100px">

            <template v-for="(item,index) in SignOffPictcure">
              <li :key="index">
                <img width="100%" height="100%" v-bind:src="item.signOffPicture">
              </li>
            </template>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="pcctureVisible1 = false">取消</el-button>
          </div>
        </el-dialog>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination
            :current-page="currentPage2"
            :page-size="pageSize2"
            @size-change="handleSizeChange2"
            @current-change="handleCurrentChange2"
            layout="total,sizes,prev, pager, next, jumper"
            :total="total2" style="float: right">
          </el-pagination>
        </el-col>
      </section>
    </el-tab-pane>
    <!--以下为异常回单-->
    <el-tab-pane label="异常回单">
      <section>
        <!--工具条-->
        <search-bar more-display>
          <el-row>
            <el-col :span="8">
              <el-form-item label="客户名称">
                <el-input  v-model="abnormal['LIKE_order.memberUserName']" placeholder="请输入客户名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="订单编号">
                <el-input  v-model="abnormal.LIKE_orderNumber" placeholder="请输入订单编号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="收货人">
                <el-input  v-model="abnormal.LIKE_sendContactName"
                          placeholder="请输入收货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <!-- todo
            <el-col :span="8">
              <el-form-item label="签收日期">
                <el-date-picker
                  v-model="abnormalPicker"
                  type="daterange"
                  align="right"
                  placeholder="选择日期范围"
                  :picker-options="pickerOptions2"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>-->
            <el-col :span="8">
              <el-form-item label="发货人">
                <el-input  v-model="abnormal.LIKE_shipmentsContactName"
                          placeholder="请输入发货人名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </search-bar>
        <el-col :span="24" style="margin-bottom: 10px">
          <el-button type="primary">导出</el-button>
          <el-button type="primary" @click="abnormalBarResert" style="float: right">重置</el-button>
          <el-button type="primary" @click="abnormalBarSearch" style="float: right">查询</el-button>
        </el-col>
        <el-table :data="abnormalTableData" highlight-current-row border max-height="600"
                  @selection-change="selsChange3" v-loading="listLoading3" style="width: 100%;">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column prop="orderNumber" label="订单编号" width="150" >
          </el-table-column>
          <el-table-column prop="orderCreateDate" label="下单日期" width="175" >
          </el-table-column>
          <el-table-column prop="signDate" label="签收日期" width="175" >
          </el-table-column>
          <el-table-column prop="receiptWayName" label="回单类型" width="130" >
          </el-table-column>
          <el-table-column prop="abnormalName" label="异常状态" width="110">
          </el-table-column>
          <el-table-column prop="memberUserName" label="客户名称" >
          </el-table-column>
          <el-table-column prop="shipmentsContactName" label="发货人" width="110" >
          </el-table-column>
          <el-table-column prop="shipmentsContactPhone" label="发货人手机" width="140" >
          </el-table-column>
          <el-table-column prop="sendContactName" label="收货人" width="110" >
          </el-table-column>
          <el-table-column prop="sendContactPhone" label="收货人手机" width="140" >
          </el-table-column>
          <el-table-column prop="sendAddress" label="操作" width="100" >
            <template slot-scope="scope">
              <el-button type="primary"
                         @click="examineAbnormal(scope.$index, scope.row)">
                查看
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination
            :current-page="currentPage3"
            :page-size="pageSize3"
            @size-change="handleSizeChange3"
            @current-change="handleCurrentChange3"
            layout="total,sizes,prev, pager, next, jumper"
            :total="total3" style="float: right">
          </el-pagination>
        </el-col>
        <!--异常详情  弹窗-->
        <el-dialog :title="abnormalTitle" size="tiny" :visible.sync="abnormalVisible"
                   :close-on-click-modal="false">
          <el-form label-width="100px">
            <el-table :data="abnormalDetialTableData" highlight-current-row border max-height="600"
                      @selection-change="selsChange4" v-loading="listLoading" style="width: 100%;">
              <el-table-column prop="acquirerName" label="异常类型" width="130" >
              </el-table-column>
              <el-table-column prop="abnormalExplain" label="异常描述" width="400" >
              </el-table-column>
            </el-table>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="abnormalVisible = false">取消</el-button>
          </div>
        </el-dialog>
      </section>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import {searchDictEntitys} from '../../api/customer/maintain.js';
import {
  saveSpecialReceipt,
  getSignOffPicture,
  getSpecialReceiptBySignOffId
} from '../../api/stowage/SpecialReceipt.js';
import {
  getSignOffPage
} from '../../api/stowage/SingIn';

export default {
  data () {
    return {
      // ----------------------待收取start------------------------------------------------------------------------------------

      // 日期控件
      pickerOptions2: {
        shortcuts: [{
          text: '最近一周',
          onClick (picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick (picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick (picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      // 异常回单--查看详情

      abnormalTitle: '查看详情',
      condition: {
        name: '',
        number: ''
      },

      // 未收取--查看图片
      pictureTitle: '查看图片',
      waitReturnAbnormalTialogTitle: '异常登记',
      // 待返还--查看图片
      pictureTitle1: '查看图片',
      waitReturnTialogTitle: '回单返还',
      waitGatherAbnormalTialogTitle: '异常登记',
      waitGatherTialogTitle: '回单收取',
      SignOffPictcure: [], // 未收取-- 查看图片
      pcctureVisible: false, // 查看图片
      pcctureVisible1: false, // 查看图片
      sels: [],
      sels1: [],
      sels2: [],
      sels3: [],
      sels4: [],
      gatherDate: null, // 收取日期
      waitGatherMemberUsers: [], // 待收取--会员数组
      receiptWay: [], // 待收取  回单类型

      waitGatherSendContactName: '', // 待收取  --收货人
      waitGatherShipmentsContactName: '', // 待收取  --发货人
      searchBarCreateDate3: '', // 签收日期
      waitGatherTableData: [], // 待收取--表格
      listLoading: false,
      listLoading1: false,
      listLoading2: false,
      listLoading3: false,
      waitGatherVisible: false, // 待收取---回单收取
      waitGatherAbnormalVisible: false, // 待收取---异常登记
      currentWaitGatherId: [], // 待收取--当前选取的ID

      waitGatherAbnormalModel: {
        'id': null,
        'orderId': null,
        'orderNumber': null,
        'freightNumber': null,
        'acquirerName': null,
        'specialReceiptStatus': null,
        'acquirerDate': null,
        'isAbnormal': null,
        'abnormal': null,
        'abnormalExplain': null,
        'remark': null,
        'cancelName': null,
        'cancelCause': null,
        'signOffId': null,
        'isStatus': null,
        'acquirerDateTemp': null,
        'cancelDate': null
      },

      waitGatherModel: {
        'id': null,
        'orderId': null,
        'orderNumber': null,
        'freightNumber': null,
        'acquirerName': null,
        'specialReceiptStatus': null,
        'acquirerDate': null,
        'isAbnormal': null,
        'abnormal': null,
        'abnormalExplain': null,
        'remark': null,
        'cancelName': null,
        'cancelCause': null,
        'signOffId': null,
        'isStatus': null,
        'acquirerDateTemp': null,
        'cancelDate': null
      },
      // ----------------------待收取end--------------------------------------------------------------------------------------

      //  -------------------------待返还  start
      waitReturnreceiptWay: [], // 待返还    回单类型
      waitReturnPicker: '', // 待返还     签收日期
      waitReturnPicker2: '', // 待返还     收单日期
      waitReturnShipmentsContactName: '', // 待返还     发货人
      waitReturnTableData: [], // 待返还     表格
      waitReturnVisible: false, // 待收取---回单收取
      waitReturnAbnormalVisible: false, // 待收取---异常登记
      abnormalVisible: false, // 异常回单--异常详情

      waitReturnAbnormalValue: '', // 待返还   异常类型
      waitReturnAbnormal: [], // 待返还   异常类型

      waitReturnModel: {
        'id': null,
        'orderId': null,
        'orderNumber': null,
        'freightNumber': null,
        'acquirerName': null,
        'specialReceiptStatus': null,
        'acquirerDate': null,
        'isAbnormal': null,
        'abnormal': null,
        'abnormalExplain': null,
        'remark': null,
        'cancelName': null,
        'cancelCause': null,
        'signOffId': null,
        'isStatus': null,
        'acquirerDateTemp': null,
        'returnDate': null,
        'cancelDate': null
      },

      waitReturnAbnormalModel: {
        'id': null,
        'orderId': null,
        'orderNumber': null,
        'freightNumber': null,
        'acquirerName': null,
        'specialReceiptStatus': null,
        'acquirerDate': null,
        'isAbnormal': null,
        'abnormal': null,
        'abnormalExplain': null,
        'remark': null,
        'cancelName': null,
        'cancelCause': null,
        'signOffId': null,
        'isStatus': null,
        'acquirerDateTemp': null,
        'returnDate': null,
        'cancelDate': null
      },
      alreadyReturnSendContactName: '', // 已返还    收货人
      alreadyReturnOrderId: '', // 已返还    签收时间
      alreadyReturnPicker: '', // 已返还    会员
      alreadyReturnShipmentsContactName: '', // 已返还    发货人
      alreadyReturnPicker2: '', // 已返还    收单时间
      alreadyReturnPicker3: '', // 已返还    返单时间
      alreadyReturnreceiptWay: [], // 已返还    回单类型
      alreadyReturnTableData: [], //  已返还   表格
      //  --------------------------已返还  end

      //  ----------------------------异常回单       start
      abnormalReceiptWay: [], // 异常回单 --
      abnormalMemberUsers: [], // 异常回单 --
      abnormalSendContactName: '', // 异常回单 --
      abnormalOrderId: '', // 异常回单 --
      abnormalPicker: '', // 异常回单 --
      abnormalShipmentsContactName: '', // 异常回单 --
      abnormalTableData: [],
      abnormalDetialTableData: [],

      specialReceiptModel: {
        'id': null,
        'orderId': null,
        'orderNumber': null,
        'freightNumber': null,
        'acquirerName': null,
        'memberUserId': null,
        'specialReceiptStatus': null,
        'acquirerDate': null,
        'isAbnormal': null,
        'abnormal': null,
        'abnormalExplain': null,
        'remark': null,
        'cancelName': null,
        'cancelCause': null,
        'cancelDate': null,
        'isStatus': null,
        'signOff': null

      },
      total: 0,
      currentPage: 1,
      pageSize: 10,
      sortProp: null,
      sortOrder: 'ascending',
      waitGather: {
        LIKE_shipmentsContactName: null,
        LIKE_sendContactName: null,
        LIKE_orderNumber: null,
        'LIKE_order.memberUserName': null
      },
      waitReturn: {
        LIKE_shipmentsContactName: null,
        LIKE_sendContactName: null,
        LIKE_orderNumber: null,
        'LIKE_order.memberUserName': null
      },
      alreadyReturn: {
        LIKE_shipmentsContactName: null,
        LIKE_sendContactName: null,
        LIKE_orderNumber: null,
        'LIKE_order.memberUserName': null
      },
      abnormal: {
        LIKE_shipmentsContactName: null,
        LIKE_sendContactName: null,
        LIKE_orderNumber: null,
        'LIKE_order.memberUserName': null
      },
      total1: 0,
      currentPage1: 1,
      pageSize1: 10,
      sortProp1: null,
      sortOrder1: 'ascending',

      total2: 0,
      currentPage2: 1,
      pageSize2: 10,
      sortProp2: null,
      sortOrder2: 'ascending',

      total3: 0,
      currentPage3: 1,
      pageSize3: 10,
      sortProp3: null,
      sortOrder3: 'ascending',

      acquirerDate: '',
      acquirerDate1: '',
      returnDate: '',
      returnDate1: '',
      waitReturn1: ''
    };
  },

  methods: {
    abnormalBarResert () {
      this.$ue.resetObjNull(this.abnormal);
    },
    // 异常回单的查询
    abnormalBarSearch () {
      this.loadSignOffPage('NOTEQ_receiptWay=101002003;ISNOTNULL_specialReceiptsList.abnormal;' + this.$ue.objToFilter(this.abnormal),
        this.currentPage3,
        this.pageSize3,
        result => {
          this.abnormalTableData = result.detailModelList;
          this.total3 = result.totalCount;
          this.listLoading3 = false;
        }
      );
    },
    alreadyReturnReset () {
      this.$ue.resetObjNull(this.alreadyReturn);
    },
    alreadyReturnSearch () {
      this.loadSignOffPage('EQ_receiptStatus=101011003;EQ_signOffStatus=101009002;NOTEQ_receiptWay=101002003;' + this.$ue.objToFilter(this.alreadyReturn),
        this.currentPage2,
        this.pageSize2,
        result => {
          this.alreadyReturnTableData = result.detailModelList;
          this.total2 = result.totalCount;
          this.listLoading2 = false;
        }
      );
    },
    waitReturnRestert () {
      this.$ue.resetObjNull(this.waitReturn);
    },
    waitReturnSearch () {
      this.listLoading1 = true;
      this.loadSignOffPage('EQ_receiptStatus=101011002;EQ_signOffStatus=101009002;NOTEQ_receiptWay=101002003;' + this.$ue.objToFilter(this.waitReturn),
        this.currentPage1,
        this.pageSize1,
        result => {
          this.waitReturnTableData = result.detailModelList;
          this.total1 = result.totalCount;
          this.listLoading1 = false;
        }
      );
    },
    examineAbnormal (index, row) {
      this.abnormalVisible = true;
      getSpecialReceiptBySignOffId(row.id).then((res) => {
        if (res.data.successFlg === true) {
          this.abnormalDetialTableData = res.data.detailModelList;
          this.currentPage3 = res.data.currPage;
          this.total3 = res.data.totalCount;
          this.pageSize3 = res.data.pageSize;
          this.listLoading3 = false;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    // 待收取--  查看图片
    examinePicture (index, row) {
      getSignOffPicture(row.id).then((res) => {
        if (res.data.successFlg === true) {
          this.SignOffPictcure = res.data.detailModelList;
          this.pcctureVisible = true;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    // 待返还--  查看图片
    examinePicture1 (index, row) {
      getSignOffPicture(row.id).then((res) => {
        if (res.data.successFlg === true) {
          this.SignOffPictcure = res.data.detailModelList;
          this.pcctureVisible1 = true;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },

    // 待收取--查询
    waitGatherSearch () {
      this.listLoading = true;
      this.loadSignOffPage('EQ_receiptStatus=101011001;EQ_signOffStatus=101009002;NOTEQ_receiptWay=101002003;' + this.$ue.objToFilter(this.waitGather),
        this.currentPage,
        this.pageSize,
        result => {
          this.waitGatherTableData = result.detailModelList;
          this.total = result.totalCount;
          this.listLoading = false;
        }
      );
    },
    // 待收取 查询 里的重置
    waitGatherResert () {
      this.$ue.resetObjNull(this.waitGather);
    },
    // 待收取---回单收取-的保存方法
    saveWaitGather () {
      if (this.currentWaitGatherId.length > 0) {
        this.waitGatherModel.signOffId = this.currentWaitGatherId;
      }
      this.waitGatherModel.isStatus = '101011001';
      this.$refs['waitGatherModel'].validate((valid) => {
        if (valid) {
          saveSpecialReceipt(this.waitGatherModel).then((res) => {
            if (res.data.successFlg === true) {
              this.waitGatherVisible = false;
              this.waitGatherSearch();
              this.waitReturnSearch();
            } else {
              this.$message.error(res.data.errorMsg);
            }
          }).catch(function (error) {
            console.log(error);
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },

    // 待收取--异常登记
    savewaitGatherAbnormal () {
      if (this.currentWaitGatherId.length > 0) {
        this.waitGatherAbnormalModel.signOffId = this.currentWaitGatherId;
      }
      this.waitGatherAbnormalModel.isStatus = '111111111';
      this.$refs['waitGatherAbnormalModel'].validate((valid) => {
        if (valid) {
          saveSpecialReceipt(this.waitGatherAbnormalModel).then((res) => {
            if (res.data.successFlg === true) {
              this.waitGatherAbnormalVisible = false;
              this.waitGatherSearch();
              this.waitReturnSearch();
            } else {
              this.$message.error(res.data.errorMsg);
            }
          }).catch(function (error) {
            console.log(error);
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },

    // 待返还  --异常登记
    savewaitReturnAbnormal () {
      if (this.currentWaitGatherId.length > 0) {
        this.waitReturnAbnormalModel.signOffId = this.currentWaitGatherId;
      }
      this.waitReturnAbnormalModel.isStatus = '111111111';
      this.$refs['waitReturnAbnormalModel'].validate((valid) => {
        if (valid) {
          saveSpecialReceipt(this.waitReturnAbnormalModel).then((res) => {
            if (res.data.successFlg === true) {
              this.waitReturnAbnormalVisible = false;
              this.waitGatherSearch();
              this.waitReturnSearch();
            } else {
              this.$message.error(res.data.errorMsg);
            }
          }).catch(function (error) {
            console.log(error);
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },

    // 待返还--回单返还的保存方法
    saveWaitReturn () {
      if (this.currentWaitGatherId.length > 0) {
        this.waitReturnModel.signOffId = this.currentWaitGatherId;
      }
      this.waitReturnModel.isStatus = '101011002';
      this.$refs['waitReturnModel'].validate((valid) => {
        if (valid) {
          this.waitReturnModel.returnDate = this.waitReturnModel.returnDate.toJSON();
          saveSpecialReceipt(this.waitReturnModel).then((res) => {
            if (res.data.successFlg === true) {
              this.waitReturnVisible = false;
              this.waitGatherSearch();
              this.waitReturnSearch();
            } else {
              this.$message.error(res.data.errorMsg);
            }
          }).catch(function (error) {
            console.log(error);
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },

    // 多选操作
    selsChange4 (sels) {
      this.sels4 = sels;
    },
    // 待收取---回单收取
    waitGatherBtn () {
      console.log(this.currentWaitGatherId);
      if (this.$refs['waitGatherModel']) {
        this.$refs['waitGatherModel'].resetFields();
      }
      this.currentWaitGatherId = this.sels.map(item => item.id);
      if (this.currentWaitGatherId.length === 0) {
        this.$message.error('请选择数据！');
        return;
      }
      this.waitGatherVisible = true;
    },

    // 待返还--异常登记
    abnormalRegister () {
      this.currentWaitGatherId = this.sels1.map(item => item.id);
      if (this.currentWaitGatherId.length === 0) {
        this.$message.error('请选择数据！');
        return;
      }
      this.waitReturnAbnormalVisible = true;
    },

    // 待返还--异常登记
    gatherAbnormalRegister () {
      this.currentWaitGatherId = this.sels.map(item => item.id);
      if (this.currentWaitGatherId.length === 0) {
        this.$message.error('请选择数据！');
        return;
      }
      this.waitGatherAbnormalVisible = true;
    },

    // 待返还---回单返还
    waitReutrn () {
      if (this.$refs['waitReturnModel']) {
        this.$refs['waitReturnModel'].resetFields();
      }
      this.currentWaitGatherId = this.sels1.map(item => item.id);
      if (this.currentWaitGatherId.length === 0) {
        this.$message.error('请选择数据！');
        return;
      }
      this.waitReturnVisible = true;
    },
    // 待返还--异常类型
    waitReturnAbnormalSelect () {
      searchDictEntitys('101012').then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.waitReturnAbnormal = res.data.detailModelList;
        }
      });
    },
    // 多选操作
    selsChange (sels) {
      this.sels = sels;
    },
    // 每页几条操作
    handleSizeChange (val) {
      this.pageSize = val;
      this.waitGatherSearch();
    },
    // 第几页操作
    handleCurrentChange (val) {
      this.currentPage = val;
      this.waitGatherSearch();
    },
    // 多选操作
    selsChange1 (sels) {
      this.sels1 = sels;
    },
    // 每页几条操作
    handleSizeChange1 (val) {
      this.pageSize1 = val;
      this.waitReturnSearch();
    },
    // 第几页操作
    handleCurrentChange1 (val) {
      this.currentPage1 = val;
      this.waitReturnSearch();
    },
    // 多选操作
    selsChange2 (sels) {
      this.sels2 = sels;
    },
    // 每页几条操作
    handleSizeChange2 (val) {
      this.pageSize2 = val;
      this.alreadyReturnSearch();
    },
    // 第几页操作
    handleCurrentChange2 (val) {
      this.currentPage2 = val;
      this.alreadyReturnSearch();
    },
    // 多选操作
    selsChange3 (sels) {
      this.sels3 = sels;
    },
    // 每页几条操作
    handleSizeChange3 (val) {
      this.pageSize3 = val;
      this.abnormalBarSearch();
    },
    // 第几页操作
    handleCurrentChange3 (val) {
      this.currentPage3 = val;
      this.abnormalBarSearch();
    },
    loadSignOffPage (filters, page, size, fn) {
      getSignOffPage({
        filters: filters,
        sorts: '',
        page: page,
        size: size
      }).then(res => {
        if (res.data.successFlg) {
          fn(res.data);
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    }
  },
  mounted () {
    this.$store.commit('initDict');
    this.waitGatherSearch();
    this.waitReturnSearch();
    this.alreadyReturnSearch();
    this.abnormalBarSearch();
  }
};
</script>
